$(function () {
    console.log(111);
    // 拿到id，从地址中拿到id
    let arr = location.href.split('=');
    console.log(arr);
    let url = new URL(location.href);

    console.log(location.search);

    let id = new URLSearchParams(location.search).get('id') || 0

    console.log(id);





    if (id > 0) {
        console.log(44444);

        axios.get(`${host}/blogs/${id}`).then((res) => {
            // 处理响应 成功获得id对应的博客，或者没找到
            console.log(res);
            let blog = res.data.data;
            // 将值设置到input上
            $('input[name=title]').val(blog.title)
            $('input[name=author]').val(blog.author)
        })
    }

})